package com.longxi.tianjintianbao.ui.activity.quality;

import android.content.Intent;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;

import com.longxi.tianjintianbao.R;
import com.longxi.tianjintianbao.ui.base.BaseActivity;
import com.longxi.tianjintianbao.ui.presenter.quality.QualityItemAtPresenter;
import com.longxi.tianjintianbao.ui.view.quality.IQualityItemAtView;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

import butterknife.BindView;

public class QualityItemActivity extends BaseActivity<IQualityItemAtView, QualityItemAtPresenter> implements IQualityItemAtView {

    @BindView(R.id.btnLogin)
    Button mBtnLogin;

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_quality_item;
    }

    @Override
    public void initData() {
        super.initData();
        mPresenter.setBar();
        mPresenter.initAdapter();
        mRefreshLayout.setOnRefreshListener(new OnRefreshListener() {

            @Override
            public void onRefresh(RefreshLayout refreshLayout) {
                mPresenter.getQualityItem();
            }

        });
        mPresenter.getQualityItem();
    }

    @Override
    public void initListener() {
        super.initListener();
        mBtnLogin.setOnClickListener(v -> mPresenter.goFinshOrChange());
    }

    @Override
    protected QualityItemAtPresenter createPresenter() {
        return new QualityItemAtPresenter(this);
    }

    @Override
    public SmartRefreshLayout getRefreshLayout() {
        return mRefreshLayout;
    }

    @Override
    public RecyclerView getRvContent() {
        return mRvContent;
    }

    @Override
    public Button getBtnLogin() {
        return mBtnLogin;
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        mBtnLogin.setVisibility(View.GONE);
        mPresenter.getQualityItem();
    }

}


